<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	    		xmlns:ui="http://java.sun.com/jsf/facelets"
	  			xmlns:h="http://java.sun.com/jsf/html"
	  			xmlns:f="http://java.sun.com/jsf/core"
	  			xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:a="http://richfaces.org/a4j"
				template="#{theme.template}">

<!-- content -->
<ui:define name="content">

<div class="section">

    <span class="errors">
       <h:messages globalOnly="true"/>
    </span>

    <fieldset>
        <legend>Recherche dans le dictionnaire</legend>

        <h:form id="searchCriteria">
           <h:inputText id="searchString" value="#{dictionnarySearch.searchString}" style="width: 165px;">
             <a:support event="onkeyup" actionListener="#{dictionnarySearch.find}" reRender="searchResults" />
           </h:inputText>
           <a:commandButton id="findKanjis" value="Find" action="#{dictionnarySearch.find}" reRender="searchResults"/>
           <a:status>
              <f:facet name="start">
                 <h:graphicImage value="#{theme.spinner}"/>
              </f:facet>
           </a:status>
           <br/>
           <h:outputLabel for="pageSize">Maximum results:</h:outputLabel>
           <h:selectOneMenu value="#{dictionnarySearch.pageSize}" id="pageSize">
              <f:selectItem itemLabel="5" itemValue="5"/>
              <f:selectItem itemLabel="10" itemValue="10"/>
              <f:selectItem itemLabel="20" itemValue="20"/>
           </h:selectOneMenu>
        </h:form>
    </fieldset>
</div>
<br/>
<h:form id="entries">
<a:outputPanel id="searchResults">
  <div class="section">
	<h:outputText value="No entries Found" rendered="#{entries != null and entries.rowCount==0}"/>
	<h:dataTable id="entries" value="#{entries}" var="dic" rendered="#{entries.rowCount>0}">
		<h:column>
			<f:facet name="header">Kanji spelling</f:facet>
            <h:outputLink value="view.seam">
               <f:param name="entryId" value="#{dic.id}"/>
                #{dic.kanji}
            </h:outputLink>
        </h:column>
        <h:column>
			<f:facet name="header">Kana spelling</f:facet>
			#{dic.kana.replace(".", "")}
		</h:column>
        <h:column>
			<f:facet name="header">Description</f:facet>
			#{dic.description}
		</h:column>
    </h:dataTable>
	<a:commandLink value="More results" action="#{dictionnarySearch.nextPage}" rendered="#{dictionnarySearch.nextPageAvailable}" reRender="searchResults"/>
  </div>
</a:outputPanel>
</h:form>

</ui:define>

</ui:composition>
